/**
 * 类与接口的差异
 * 1、抽象类编译后还是会产生实体，而接口不会
 * 2、ts 只支持单继承，及一个子类只能有一个父类，一个类可以实现多个接口
 * 3、接口是不能有实现，抽象类有
 */
{
  abstract class Component<T1, T2> {
    props: T1;
    state: T2;

    constructor(props: T1) {
      this.props = props;
    }
    /**
     * 1、抽象类里不能有实体
     * 2、抽象类不能实例化
     */
    abstract render(): string;

  }

  interface ILog {
    getInfo(): string;
  }

  interface IStorage extends ILog {
    save(data: string): void;
  }

  interface IMyComponentProps {
    val: number;
  }

  interface IMyComponentState {
    x: number;
  }

  class MyComponent extends Component<IMyComponentProps, IMyComponentState> implements ILog, IStorage {
    constructor(props: IMyComponentProps) {
      super(props);
      this.state = {
        x: 1
      }
    }

    render() {
      console.log(this.props.val);
      console.log(this.state.x);
      return '<MyComponent />';
    }

    getInfo() {
      console.log(12345);
      return 'asd';
    }

    save(data: string) {
      console.log('11', data);
    }
  }

  let myComponent = new MyComponent({ val: 1 });
  myComponent.render();
  myComponent.save('asda');
  myComponent.getInfo();
}

